package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.AttentionTeacherVO;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hedgehog.ratingbar.RatingBar;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：关注页专家列表
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：jiabo
 * 创建时间：2017/3/24 14:32
 * 修改备注：
 * ================================================
 */
public class AttentionTeacherHolder extends BaseViewHolder<AttentionTeacherVO> {

    private SimpleDraweeView sdvHead; // 头像
    private TextView tvName; // 用户名
    private TextView tvDes; //  描述
    private TextView tvLevel; // 职称
    private TextView tvWork; // 工作地点
    private RatingBar ratingBar;

    public AttentionTeacherHolder(ViewGroup parent) {
        super(parent, R.layout.item_attention_expert);

        sdvHead = $(R.id.item_attention_expert_iv_head);
        tvName = $(R.id.item_attention_expert_tv_name);
        tvDes = $(R.id.item_attention_expert_tv_des);
        tvLevel = $(R.id.item_attention_expert_tv_level);
        tvWork = $(R.id.item_attention_expert_tv_work);
        ratingBar = $(R.id.item_attention_expert_ab_stars);
    }

    @Override
    public void setData(AttentionTeacherVO data) {
        super.setData(data);

        tvName.setText(data.getAgriTeacher().getName());
        if (StringUtil.isStrEmpty(data.getAgriTeacher().getTitle())) {
            tvLevel.setVisibility(View.GONE);
        } else {
            tvLevel.setText(data.getAgriTeacher().getTitle());
            tvLevel.setVisibility(View.VISIBLE);
        }

        tvDes.setText(data.getAgriTeacher().getProfession());
        tvWork.setText(data.getAgriTeacher().getWorkUnit());


        FrescoUtil.showImageSmall(data.getAgriTeacher().getImg(), sdvHead);
//        if (!TextUtils.isEmpty(data.getAgriTeacher().getTrainScore().toString())) {
//            ratingBar.setStar(Float.parseFloat(data.getAgriTeacher().getTrainScore().toString()));
//        }
    }
}
